package com.windgo.controller.admin;

import com.windgo.bean.MarketComment;
import com.windgo.bean.common.BasePageInfo;
import com.windgo.bean.common.BaseRespVo;
import com.windgo.bean.common.CommonData;
import com.windgo.service.CommentService;
import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

/**
 * @Author:ZhouXin
 * @Date:2022/10/12 18:26
 * @Description:
 **/
@RestController
@RequestMapping("admin")
public class CommentController {

    @Autowired
    CommentService commentService;

    @GetMapping("comment/list")
    @RequiresPermissions("perms[admin:comment:list]")
    public BaseRespVo list(BasePageInfo info, Integer userId, Integer valueId) {
        CommonData<MarketComment> data = commentService.list(info, userId, valueId);
        return BaseRespVo.ok(data);
    }

    @PostMapping("comment/delete")
    @RequiresPermissions("perms[admin:comment:delete]")
    public BaseRespVo delete(@RequestBody MarketComment comment){
        Integer id = comment.getId();
        commentService.delete(id);
        return BaseRespVo.ok();
    }


}